<?
	$mode = $_POST["mode"];
	
	if ( $mode == 'd' )
		header("Content-Type: application/json");

	require_once "../../_func/__Global.php";
	require_once "../../_func/__Local.php";
	require_once "../../_func/__MysqlFunc.php";
	require_once "../../_func/_MngFunc.php";

	$resultCode = "0";
	$successCnt = 0;
	$resultHTML = "";
	
	if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
		//sorting
		if ( $mode == 's' ) {
			
			//someting do	
			if ( is_array( $due_dispsArr ) ) {

				foreach( $due_dispsArr as $key => $item )
				{
					foreach( $item as $name => $mseq )
					{
						//find key code_display,code_seq
						$code_display = explode(",",$mseq);
						$array = array( 'code_display' => $code_display[0],);
/*
						if ( $code_display[1] != null ) {
							$resultHTML .= "[code_seq:".$code_display[1]."]";
							$resultHTML .= "[code_display:".$code_display[0]."]";
						}
*/
						if ( $code_display[1] != null ) {
							//코드업데이트
							$result = CodeUpdate($array, $code_display[1]);
							unset($array);
						}
					}
				}
			}
		}
		//delete	
		else {
			if ( is_array( $handle_seq ) ) {
				foreach( $handle_seq as $key => $item )
				{
					foreach( $item as $name => $mseq )
					{
						if ( $name=="value") {
							//회원삭제
							if ( $flag == "member" ) 
								$result = MemberDelete($mseq);
							//농가삭제
							else if ( $flag == "farm" ) 
								$result = FarmDelete($mseq);
							//농협삭제
							else if ( $flag == "NH" )
								$result = NHDelete($mseq);
							//코드삭제
							else if ( strpos($flag,"item")>=0 || strpos($flag,"other")>=0 || strpos($flag,"destination")>=0 )							
								$result = CodeDelete($mseq);							
								
							if ($result)
								$successCnt++;
						}
					}
				}
				if ( $successCnt > 0 )
					$resultCode = "200";
			}
		}
	}
	
	if ( $mode == 's' ) {
		echo $resultHTML;
	}
	else
	if ( $mode == 'd' ) {
		$result_array['resultCode'] = $resultCode;
		$result_array['successCnt'] = $successCnt;
		$result_array = json_encode( $result_array );
		echo $result_array;
	}
?>